package cn.powerone.scm.controller;

import java.util.List;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import cn.powerone.common.annotation.Log;
import cn.powerone.common.core.controller.BaseController;
import cn.powerone.common.core.domain.AjaxResult;
import cn.powerone.common.enums.BusinessType;
import cn.powerone.scm.domain.ScmOrderPayment;
import cn.powerone.scm.service.IScmOrderPaymentService;
import cn.powerone.common.utils.poi.ExcelUtil;
import cn.powerone.common.core.page.TableDataInfo;

/**
 * 付款Controller
 * 
 * @author PowerOne
 * @date 2025-08-05
 */
@RestController
@RequestMapping("/scm/scmOrderPayment")
public class ScmOrderPaymentController extends BaseController
{
    @Autowired
    private IScmOrderPaymentService scmOrderPaymentService;

    /**
     * 查询付款列表
     */
    @PreAuthorize("@ss.hasPermi('scm:scmOrderPayment:list')")
    @GetMapping("/list")
    public TableDataInfo list(ScmOrderPayment scmOrderPayment)
    {
        startPage();
        List<ScmOrderPayment> list = scmOrderPaymentService.selectScmOrderPaymentList(scmOrderPayment);
        return getDataTable(list);
    }

    /**
     * 导出付款列表
     */
    @PreAuthorize("@ss.hasPermi('scm:scmOrderPayment:export')")
    @Log(title = "付款", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ScmOrderPayment scmOrderPayment)
    {
        List<ScmOrderPayment> list = scmOrderPaymentService.selectScmOrderPaymentList(scmOrderPayment);
        ExcelUtil<ScmOrderPayment> util = new ExcelUtil<ScmOrderPayment>(ScmOrderPayment.class);
        util.exportExcel(response, list, "付款数据");
    }

    /**
     * 获取付款详细信息
     */
    @PreAuthorize("@ss.hasPermi('scm:scmOrderPayment:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(scmOrderPaymentService.selectScmOrderPaymentById(id));
    }

    /**
     * 新增付款
     */
    @PreAuthorize("@ss.hasPermi('scm:scmOrderPayment:add')")
    @Log(title = "付款", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ScmOrderPayment scmOrderPayment)
    {
        return toAjax(scmOrderPaymentService.insertScmOrderPayment(scmOrderPayment));
    }

    /**
     * 修改付款
     */
    @PreAuthorize("@ss.hasPermi('scm:scmOrderPayment:edit')")
    @Log(title = "付款", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ScmOrderPayment scmOrderPayment)
    {
        return toAjax(scmOrderPaymentService.updateScmOrderPayment(scmOrderPayment));
    }

    /**
     * 删除付款
     */
    @PreAuthorize("@ss.hasPermi('scm:scmOrderPayment:remove')")
    @Log(title = "付款", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(scmOrderPaymentService.deleteScmOrderPaymentByIds(ids));
    }
}
